<template>
	<view class="content">
		<view class="item" @click="scanCodeClick()">
			<image class="icon" src="@/static/public/codeIcon.png"></image>
			扫码核销
		</view>
		<view class="item" @click="navGo('/pages/integralLst/integralLst')">
			<image src="@/static/me/jilu.png" class="icon"></image>
			余额明细
		</view>
		<view class="btn logOut" @click="logOut()">退出登录</view>
		<!-- <privacyPopup ref="privacyPopupRef" :privacyContractName='privacyContractName'></privacyPopup> -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				privacyContractName: '',
			}
		},
		onLoad() {
			// let isArgee = uni.getStorageSync('isArgee') || ''
			// if (isArgee == '') {
			// 	this.setPrivacy()
			// }
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			getUserInfo(){
				let that = this
				let adminId = uni.getStorageSync('adminId')
				let token = uni.getStorageSync('token')
				uni.request({
					url: 'https://api.shaoyanghmk.cn/admin/' + adminId, //仅为示例，并非真实接口地址。
					header: {
						'Token': token //自定义请求头信息
					},
					success: (res) => {
						console.log(res.data);
						let data = res.data
					}
				});
			},
			setPrivacy() {
				uni.setStorageSync('isArgee', false)
				uni.getPrivacySetting({
					success: res => {
						console.log(
							res
						) // 返回结果为: res = { needAuthorization: true/false, privacyContractName: '《xxx隐私保护指引》' }
						// 隐私弹框
						if (res.needAuthorization) {
							console.log('触发隐私弹框', res.privacyContractName)
						}
						this.privacyContractName = res.privacyContractName
					},
					fail: () => {

					},
					complete: () => {

					}
				})
			},
			isShowPrivacy() {
				let isArgee = uni.getStorageSync('isArgee')
				this.isArgee = isArgee
				if (!isArgee) {
					this.$nextTick(() => {
						this.$refs.privacyPopupRef.openPopup()
					})
				}
			},
			navGo(path) {
				uni.navigateTo({
					url: path
				})
				return 
				if (!this.$tools.getToken()) {
					this.$tools.showMsg('请登录')
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 600)
					return
				}
				uni.navigateTo({
					url: path
				})
			},
			scanCodeClick() {
				 uni.navigateTo({
				 	url:'/pages/index/scanCode'
				 })
				return
				if (!this.$tools.getToken()) {
					this.$tools.showMsg('请登录')
					setTimeout(() => {
						uni.navigateTo({
							url: '/pages/login/login'
						})
					}, 600)
					return
				}
				let that = this
				uni.scanCode({
					success: function(res) {
						that.navGo(`/pages/orderDetail/orderDetail?id=${res.result}`)
					},
					fail(err) {
						console.log('条码内容：err' + err.result);
						console.log('条码内容：err' + err.scanType);
					}
				});
			},
			logOut() {
				// uni.navigateTo({
				// 	url:'/pages/login/bindPhone/bindPhone'
				// })
				// return 
				uni.showModal({
					title: '提示',
					content: `是否退出当前账号`,
					confirmText: '确认',
					confirmColor: '#e43130',
					success(res) {
						if (res.confirm) {
							uni.clearStorageSync()
							uni.navigateTo({
								url: '/pages/login/login'
							})
						} else {

						}
					}
				})
			}
		}
	}
</script>
<style>
	page {
		background: #fff;
		height: 100vh;
	}
</style>
<style lang="scss" scoped>
	.logOut {
		position: fixed;
		bottom: 64rpx;
		left: 0;
		right: 0;
		margin-top: 64rpx;
		line-height: 90rpx;
		text-align: center;
		color: #fff;
		margin: 0 auto;
		width: 670rpx;
		height: 90rpx;
	}

	.content {
		margin-top: 24rpx;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		justify-content: space-between;
	}

	.item {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 300rpx;
		width: 48%;
		border: 1rpx solid #e4e4e4;
		margin-bottom: 24rpx;

		.icon {
			width: 76rpx;
			height: 76rpx;
			margin-bottom: 18rpx;
		}
	}
</style>